
/*
 * $Id: IOnwatchTaskDAO.java,v 1.9 2009/05/28 14:57:19 navdeep_mahajan Exp $
 * 
 * Copyright (C) 2008 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.common.database.dao;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ge.healthcare.autosc.common.database.pojo.ActOnwatchTask;
import com.ge.healthcare.autosc.common.database.pojo.ActTask;

public interface IOnwatchTaskDAO extends IBaseDAO {
	/**
	 * This method accepts the pojo and starts a new transaction so that it can
	 * always save the pojo in DB irrespective the calling transaction was
	 * success/failure
	 * 
	 * @param pojo
	 *            - pojo to save
	 */
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void saveAlways(Object pojo);

	
	/**
	 * GEt ActOnwatchTask by primary key
	 * @param onwatchTaskId
	 * @return
	 */
	public ActOnwatchTask getByOnwatchTaskID(Long onwatchTaskId);
	
	/**
	 * get ActOnwatchTask by Task and TaskList id 
	 * @param taskId
	 * @param taskListId
	 * @return
	 */
	public ActOnwatchTask getOnwatchTaskByTaskAndTaskList(Long taskListId, Long taskId); 
	
	/**
	 * get ActOnwatchTask by system and status
	 * @param systemId	System Id representing the system
	 * @param codeName	ActTask code
	 * @param status	ActOnwatchTask status
	 * @return
	 */
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public List<ActOnwatchTask> markOnwatchTaskBySystemAndStatus(String systemId, String codeName, String status);
	
	/**
	 * 
	 * @param systemId
	 * @param codeName
	 * @param status
	 * @return
	 */
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void releaseOnwatchTaskByTaskListId(Long onwatchTaskListId);
	
	/**
	 * get ActOnwatchTask by taskId
	 * @param taskId
	 * @return
	 */
	public List<ActOnwatchTask> getByTaskId(Long taskId);
	
	/**
	 * get new onwatchTaskListId
	 * @return
	 */
	public Long getNewOnwatchTaskListId();
	
	/**
	 * Saves initial task to the OnWatch Task Queue
	 * @param task - Act Task
	 */
	public void saveInitialOnWatchTask(ActTask task);
	
	/**
	 * Returns all tasks in NEW state in on watch queue
	 * @return
	 */
	public List<ActOnwatchTask> getAllNewTasks();
	
	/**
	 * Deletes on watch tasks by task id
	 * @param taskId
	 */
	public void deleteByTaskId(Long taskId);
}
